<script type="text/javascript">
$(function(){	
	var pg = App.soagov.macRpcMain.ui, pp = pg.params,
		tabs = pg.find('.tabs'),
		refGd = pg.seek('refGd'),
		svcGd = pg.seek('svcGd'),
		hd = pg.children('.head'),
		title = hd.seek('title');
	
	title.text(pp.reg.key);
		
	function init(o) {
		var r = o.reg;
		refGd.loadData(r.referenceMap);
		svcGd.loadData(r.serviceMap);
	}
		
	//填充tabs
	tabs.mac('tabs', {
		tabWidth: 80,
		tabHeight: 32,
		items: [{
			code: 'refPl', title: '引用的服务', el: refGd
		}, {
			code: 'svcPl', title: '提供的服务', el: svcGd
		}],
	}).selectFirst();
		
	//引用的服务
	refGd.mac('grid', {
		cols : [{
			field: 'id', title : '本地的代理', width: 160,
			render: function(r, tr, me){
				return $('<span class="a"></span>').click(function(){
					App.show({
						ctx: 'soagov',
						action: 'refs',
						params: { reg: pp.reg, ref: r, all: pp.all },
					}, $.noop, pg.parent());
				}).append(r.id);
			}
		},{
			field: 'group', title : '分组', width: 120,
			render: function(r){
				return r.group;
			}
		},{
			field: 'name', title : '名称', width: 120,
			render: function(r){
				return r.name;
			}
		},{
			field: 'version', title : '版本', width: 80
		},{
			field: 'timeout', title : '超时', width: 70,
			render: function(r){
				return r.timeout +  'ms';
			}
		},{
			field: 'interfaceName', title : '接口', width: 300
		},{
			field: 'methodCt', title : '方法数', width: 200, hidden:true
		}],
		pagerLength: 1000
	});
	//提供的服务
	svcGd.mac('grid', {
		cols : [{
			field: 'ref', title : '引用的本地对象', width: 140,
			render: function(r,tr,me){
				return $('<span class="a"></span>').click(function(){
					me.load({ key: r.ref, pageNo: 1, key: '' });
				}).append(r.ref);
			}
		},{
			field: 'group', title : '分组', width: 120,
			render: function(r){
				return r.group;
			}
		},{
			field: 'name', title : '名称', width: 120,
			render: function(r){
				return r.name;
			}
		},{
			field: 'version', title : '版本', width: 80
		},{
			field: 'timeout', title : '超时', width: 70,
			render: function(r){
				return r.timeout +  'ms';
			}
		},{
			field: 'interfaceName', title : '接口', width: 310
		},{
			field: 'methodCt', title : '方法数', width: 200,hidden:true
		}],
		pagerLength: 1000
	});

	function adjust(){
		var h = pg.parent().height();
		pg.height(h);
		tabs.height(h - hd.height() - 8);
		tabs.adjust();
		h = tabs.children('.body').height();
		refGd.parent().height(h);
		refGd.adjust();
		svcGd.parent().height(h);
		svcGd.adjust();
	}
	$(window).resize(adjust);
	adjust();

	title.click(function(){
		App.show({
			ctx: 'soagov',
			action: 'macRpcMain',
			params: pp
		}, $.noop, pg.parent());
	});

	if (pp) {
		init(pp);
	}
});
</script>
<div class="head">
	<div class="title">
		当前节点:<span  class="a" name="title">XXXX</span>
	</div>
</div>
<div class="tabs"></div>
<div class="grid" name="refGd"></div>
<div class="grid" name="svcGd"></div>
